﻿@{
    Layout = null;
    int z = 0;
    EnterpriseFund.Controllers.AllowanceCalcManageController a = new EnterpriseFund.Controllers.AllowanceCalcManageController();

    
}
@model EnterpriseFund.Model.AllowanceIssue
<!DOCTYPE html>
@Html.Partial("LoadPanelPartial")
<html>
<head>
    <title></title>
       @if (false)
       {
        <script src="../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>
        <script src="../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>
       }
    <link href="@Url.Content("~/Content/Site.css", true)" rel="stylesheet" type="text/css" />

    <link href="@Url.Content("~/Content/jquery-ui.css", true)" rel="stylesheet" type="text/css" />

    <script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/jquery-ui.min.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/FloatDiv.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/regex.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Common/GetRootPath.ashx", true)" type="text/javascript"></script>

    @Html.DevExpress().GetStyleSheets(

        new StyleSheet { ExtensionType = ExtensionType.ListBox, Theme = DevExpressHelper.Theme }
)
    @Html.DevExpress().GetScripts(
        new Script { ExtensionType = ExtensionType.ListBox }
)
<script>
    $(document).ready(function () {
        $("#toolMenu").smartFloat();
        var hdjsAlert = $("#hdjsAlert").val();
        if (hdjsAlert != "") {
            alert(hdjsAlert);
        }
        if (hdjsAlert == "操作成功") {
            var hidSType = $("#hidSType").val();
            if (hidSType == "ALL") {
                window.location.href = rootPath + '/AllowanceCalcManage/';
            }
            else {
                window.location.href = rootPath + '/AllowanceCalcManage/AllowanceCalcEdit?FIssueID=' + $("#hidFIssueID").val();
            }
        }
        jsSum();
    });


    function Invalid(code, code2, code3, code4) {
        if (confirm("是否确定作废该数据？")) {
            $.ajax({
                type: 'POST',
                url: rootPath + '/AllowanceCalcManage/InvalidToIssue',
                data: { taxAuditId: code, year: code2, taxClassAllowanceNo: code3, FIssueID: $("#hidFIssueID").val() },
                success: function (result) {
                    var sdata = result.split("||");
                    if (sdata[0] == "ok") {
                        $("tr[id='" + code4 + "']").remove();

                        $("#zjse").text(sdata[1]);
                        $("#zjFAllowanceAmount").text(sdata[2]);
                        $("#zjYBTJE").text(sdata[3]);
                        $("#zjBTJE").text(sdata[4]);
                        $("#hjhs").text(sdata[5]);
                        jsSum();
                    }
                    else {
                        alert("系统异常");
                    }
                }
            });
        }
    }

    function Open(code, code2, code3, code4, code5) {
        var sum = $("#" + code5).val();
        var ybtje = $("#YBTJE").text();
        if (confirm("是否确定发送该数据？")) {
            $.ajax({
                type: 'POST',
                url: rootPath + '/AllowanceCalcManage/OpenToIssue',
                data: { taxAuditId: code, year: code2, taxClassAllowanceNo: code3, FIssueID: $("#hidFIssueID").val(), sum: sum, ybtje: ybtje },
                success: function (result) {
                    var sdata = result.split("||");
                    if (sdata[0] == "ok") {
                        $("tr[id='" + code4 + "']").remove();
                        $("#zjse").text(sdata[1]);
                        $("#zjFAllowanceAmount").text(sdata[2]);
                        $("#zjYBTJE").text(sdata[3]);
                        $("#zjBTJE").text(sdata[4]);
                        $("#hjhs").text(sdata[5]);
                        jsSum();
                    }
                    else if (sdata[0] == "ex") {
                        alert("系统异常");
                    }
                    else {
                        alert(sdata[0]);
                    }
                }
            });
        }
    }


    function delADD(code, code2, code3, code4) {
        $.ajax({
            type: 'POST',
            url: rootPath + '/AllowanceCalcManage/DelToIssue',
            data: { taxAuditId: code, year: code2, taxClassAllowanceNo: code3, FIssueID: $("#hidFIssueID").val() },
            success: function (result) {
                var sdata = result.split("||");
                if (sdata[0] == "ok") {
                    $("tr[id='" + code4 + "']").remove();

                    $("#zjse").text(sdata[1]);
                    $("#zjFAllowanceAmount").text(sdata[2]);
                    $("#zjYBTJE").text(sdata[3]);
                    $("#zjBTJE").text(sdata[4]);
                    $("#hjhs").text(sdata[5]);
                    jsSum();
                }
                else {
                    alert("系统异常");
                }
            }
        });
    }

    function jsSum() {
        var sum = 0;

        var controls = document.getElementsByTagName('input');
        for (var i = 0; i < controls.length; i++) {
            if (controls[i].type == 'text') {
                var s = controls[i].value;
                if (s != "") {
                    if (!isNaN(s)) {
                        sum += Number(s);
                    }
                    else {
                        text[i].value = 0;
                    }
                }
                else {
                    text[i].value = 0;
                }
            }
        }
//        var text = document.getElementsByName("BTJE");
//        for (var i = 0; i < text.length; i++) {
//            var s = text[i].value;
//            if (s != "") {
//                if (!isNaN(s)) {
//                    sum += Number(s);
//                }
//                else {
//                    text[i].value = 0;
//                }
//            }
//            else {
//                text[i].value = 0;
//            }
//        }
        $("#zjBTJE").text(sum); 
    }

    function MenuTop_emClick(source, e) {
        switch (e.item.name) {
            case "btnSubmit":
                {
                    if (confirm("是否确定发送选中数据？")) {
                        var value = "";
                        var boc = document.getElementsByName("box");
                        for (var i = 0; i < boc.length; i++) {
                            if (boc[i].checked) {
                                if (value == "") {
                                    value += value + boc[i].value;
                                }
                                else {
                                    value += "," + boc[i].value;
                                }
                            }
                        }
                        if (value != "") {
                            $("#hidcheckNoALL").val(value);
                            $("#hidSType").val("Portion");
                            Save();
                        }
                        else {
                            alert("为选中任何行！");
                        }
                    }
                    break;
                }
//            case "btnALLSubmit":
//                {
//                    if (confirm("是否确定发送全部数据？")) {
//                        $("#hidSType").val("ALL");
//                        Save();
//                    }
//                    break;
//                }
            case "btnback":
                {
                    window.location.href = rootPath + '/AllowanceCalcManage/';
                    break;
                }
        }

    }

    function checkAdd(obj) {
        var value = $("#xz").html();
        var boc = document.getElementsByName("box");
        if (value == "全选") {
            for (var i = 0; i < boc.length; i++) {
                boc[i].checked = true;
            }
            $("#xz").html("取消");
        }
        else {
            for (var i = 0; i < boc.length; i++) {
                boc[i].checked = false;
            }
            $("#xz").html("全选");
        }
    }
   
    function look(no, id) {
        window.showModelessDialog(rootPath + "/AllowanceCalcManage/LookEntry?taxClassAllowanceNo=" + no + "&FTaxAuditId=" + id, "", "dialogWidth=500px;dialogHeight=500px");
    }

    function Save() {
        form1.submit();
    }

    function ADD() {
        window.showModalDialog(rootPath + "/AllowanceCalcManage/SelectCompany?FAllowanceClassNo=" + $("#hidFAllowanceClassNo").val() + "&issueID=" + $("#hidFIssueID").val(), "", "dialogWidth=800px;dialogHeight=500px");
        window.location.reload();
    }
</script>

   <style>
    .tableStyle
{
	width:100%;
	border: solid 1px black;
		padding: 6px 5px;
	border-collapse: collapse;
}
.tableStyle td
{
}

.tableStyle .tdClass
{
	padding: 0px;
  padding: 2px 2px;
	border: solid 1px black;
}
.tableStyle th
{
	text-align: right;
	padding: 6px 5px;
	border: solid 1px black;
}
.tableStyle .button
{
	margin: 2px 0px 0px 2px;
	float: left;
}

text{border:1px solid #aecaf0;}

    </style>
</head>
<body>
    @using (Html.BeginForm("Save", "AllowanceCalcManage", FormMethod.Post, new { id = "form1" }))
    {
 @Html.DevExpress().Menu(settings =>
{
    settings.Name = "toolBarMenu";
    settings.ItemAutoWidth = false;
    settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
    settings.Styles.Style.Border.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
    settings.Styles.Style.BorderTop.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1);
    settings.Items.Add(item =>
    {
        item.Name = "btnSubmit";
        item.Text = "发送选中数据";
        item.Image.Url = Url.Content("~/Content/ControlImages/edit_add.png");
    });

    //    settings.Items.Add(item =>
    //{
    //    item.Name = "btnALLSubmit";
    //    item.Text = "发送期号";
    //    item.Image.Url = Url.Content("~/Content/ControlImages/button_add.png");
    //});
    settings.Items.Add(item =>
    {
        item.Name = "btnback";
        item.Text = "返回";
        item.Image.Url = Url.Content("~/Content/ControlImages/back.png");
    });
    settings.ClientSideEvents.ItemClick = "function(source,e){MenuTop_emClick(source,e)}";
    settings.ItemLinkMode = ItemLinkMode.ContentBounds;
}).GetHtml()
    <div>
    <table width="100%">
    <tr>
    <td align="center">
    <h1>企业扶持资金 @ViewData["FIssueNo"]</h1>
    </td>
    </tr>
    </table>
    <table class="tableStyle">
    <tr>
    <td class="tdClass" align="center"  style=" width:30px"><a href="#" onclick="checkAdd(this)"  id="xz" name="xz">全选</a></td> 
    <td class="tdClass" align="center">
    @if (ViewData["type"].ToString() == "show")
    {
    <a href="#" onclick="ADD()">增加</a> 
    }
    else
    {
        @:操作 
    }  
    </td>
    <td class="tdClass" align="center" style=" width:50px">纳税人<br />编码</td>
    <td class="tdClass" align="center">纳税人名称</td>
    <td class="tdClass" align="center" style=" width:60px">税种</td>
    <td class="tdClass" align="center">实缴税金</td>
    <td class="tdClass" align="center">基数</td>
    <td class="tdClass" align="center" >基数内<br />补贴率</td>
    <td class="tdClass" align="center" >基数外<br />补贴率<br />(补贴率)</td>
    <td class="tdClass" align="center" style=" width:50px">可补金额<br />(万元)</td> 
    <td class="tdClass" align="center" style=" width:50px">已补金额<br />(万元)</td>   
    <td class="tdClass" align="center" style=" width:60px">本期补贴<br />金额<br />(万元)</td> 
    </tr>
   @if (ViewData["showdata"] != null)
   {

       foreach (System.Data.DataRow dr in (ViewData["showdata"] as System.Data.DataTable).Rows)
       {
           z++;
           <tr id="@z">
           @if (dr["cz"] == "mx")
           {
                   <td class="tdClass" align="center"  style=" width:30px"><input type="checkbox" value="@dr["FTaxAuditId"]|@dr["FYear"]|@dr["FTaxClassAllowanceNo"]" id ='@dr["FTaxClassAllowanceNo"]@dr["NSRDZDAH"]' name='box' /></td>
                <td class="tdClass" align="center"  style=" width:100px">
                <a href="#" onclick="delADD('@dr["FTaxAuditId"]','@dr["FYear"]','@dr["FTaxClassAllowanceNo"]','@z')">删除</a>
                <a href="#" onclick="Invalid('@dr["FTaxAuditId"]','@dr["FYear"]','@dr["FTaxClassAllowanceNo"]','@z')">作废</a>
                <a href="#" onclick="Open('@dr["FTaxAuditId"]','@dr["FYear"]','@dr["FTaxClassAllowanceNo"]','@z','@dr["FTaxClassAllowanceNo"]@dr["NSRDZDAH"]BTJE')">发送</a>
                </td>
                <td class="tdClass" align="left">@dr["NSRBM"]</td>
                <td class="tdClass" align="left">@dr["NSRMC"]</td>
                                            if (dr["FTaxClassAllowanceName"] != "特殊调整")
                                            {
                <td class="tdClass" align="center"><a href="#" onclick ="look('@dr["FTaxClassAllowanceNo"]','@dr["FTaxAuditId"]')"> @dr["FTaxClassAllowanceName"] </a></td>
                                            }
                                            else
                                            {
                   <td class="tdClass" align="center"> @dr["FTaxClassAllowanceName"] </td>
                                            }
                <td class="tdClass" align="right">@dr["se"]</td>
                <td class="tdClass" align="right">@dr["FBaseAmount"]</td>
                <td class="tdClass" align="right">@dr["FInnerRate"]</td>
                <td class="tdClass" align="right">@dr["FOuterRate"]</td>
                <td class="tdClass" align="right">@dr["FAllowanceAmount"]</td>
                <td class="tdClass" align="right" id='YBTJE'>@dr["YBTJE"]</td>
                <td class="tdClass" align="right"><input type="text" onchange="jsSum()" value='@dr["BTJE"]'  style=" text-align:right; width:95%" id="@dr["FTaxClassAllowanceNo"]@dr["NSRDZDAH"]BTJE"  name="@dr["FTaxClassAllowanceNo"]@dr["NSRDZDAH"]BTJE"  style="width:80px;"  /></td>
           }
           else if (dr["cz"] == "特殊调整")
           {
                 <td class="tdClass" align="center" colspan="2"></td>
                <td class="tdClass" align="left">@dr["NSRBM"]</td>
                <td class="tdClass" align="left">@dr["NSRMC"]</td>
                <td class="tdClass" align="center">@dr["FTaxClassAllowanceName"]</td>
                <td class="tdClass" align="right"> @dr["se"]</td>
                <td class="tdClass" align="right" ></td>
                <td class="tdClass" align="right"></td>
                <td class="tdClass" align="right"></td>
                <td class="tdClass" align="right">@dr["FAllowanceAmount"]</td>
                <td class="tdClass" align="right">@dr["YBTJE"]</td> 
                <td class="tdClass" align="right" ><input type="text"  value='@dr["BTJE"]' readonly  style=" text-align:right; width:95%; background-color:#EAEAEE" id="@dr["FTaxClassAllowanceNo"]@dr["NSRDZDAH"]BTJE"  name="@dr["FTaxClassAllowanceNo"]@dr["NSRDZDAH"]BTJE"  style="width:80px;"  /></td>
           }
           else
           {
                 
                 <td class="tdClass" align="center" colspan="2">@dr["cz"]</td>
                <td class="tdClass" align="left">@dr["NSRBM"]</td>
                <td class="tdClass" align="left" id="hjhs">@dr["NSRMC"]</td>
                <td class="tdClass" align="center">@dr["FTaxClassAllowanceName"]</td>
                <td class="tdClass" align="right" id='zjse'> @dr["se"]</td>
                <td class="tdClass" align="right" >@dr["FBaseAmount"]</td>
                <td class="tdClass" align="right">@dr["FInnerRate"]</td>
                <td class="tdClass" align="right">@dr["FOuterRate"]</td>
                <td class="tdClass" align="right" id='zjFAllowanceAmount'>@dr["FAllowanceAmount"]</td>
                <td class="tdClass" align="right" id='zjYBTJE'>@dr["YBTJE"]</td>
                <td class="tdClass" align="right" id='zjBTJE'>@dr["BTJE"]</td>
           }
               
           </tr>
       }
   }
    </table>
    @Html.Hidden("hidSType", ViewData["SType"])
    @Html.Hidden("hidFIssueNo", ViewData["FIssueNo"])
        @Html.Hidden("hidFIssueID", ViewData["FIssueID"])
            @Html.Hidden("hdjsAlert", (ViewData["jsAlert"]))
    @Html.Hidden("hidFAllowanceClassNo", Model.FAllowanceClassNo)
      @Html.Hidden("hidcheckNoALL", "")
    </div>
    }
</body>
</html>

